package de.sendorian.app.forumArchive.repository;


import java.util.List;

import javax.persistence.NoResultException;

import de.sendorian.app.forumArchive.domain.Topic;

public class TopicRepository extends RepositoryBase<Topic> {

	public TopicRepository() {
		super(Topic.class);
	}

	public Topic findByName(String name) {
		try {
			return findByUniqueAttribute("name", name);
		} catch (NoResultException e) {
			logger.debug("No Topic found with name " + name);
		}
		return null;
	}


	public List<Topic> findAllBatched(int firstResult) {
		String jpql = "select e from " + entityName + " e";
		return getEntityManager().createQuery(jpql).setFirstResult(firstResult).setMaxResults(100)
		    .getResultList();
	}
}
